home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 22
/
AMIGAplus Sonderheft 22 (2000)(Falke)(DE)(Track 1 of 4)[!].iso
/
Rexx
/
Invoice.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-11-06
|
6KB
|
306 lines
/*
TimeKeep - Final Writer script
$VER: 13 Jan 1998 - Invoice.rexx
*/
options results
/* Initialize */
'CopyRuler'
Tab = '09'x
Quote = '22'x
cInvoice = 0
DataPath = "S:TimeKeep/"
'RequestText' '"Create Invoice" "ENTER Client Code" ""'
iNameCode = RESULT
if iNameCode = "" | iNameCode = "RESULT" then exit
/* Read Time Data */
if ~ open('Time', DataPath||iNameCode||".time", 'R') then do
'ShowMessage' 1 1 '"CREATE INVOICE ERROR" ".time NOT FOUND" "" "OK" "" ""'
exit
end
t = readln('Time')
parse var t '"'Client.NameCode'","'Client.Name'"'
/* Collate */
Projects = "|"; nProjects = 0 ; Expenses = 0; Work = 0
do while ~eof('Time')
t = readln('Time')
parse var t '"'tType'","'tProject'",'tInfo
if tInfo == "" then leave
if index(Projects, "|"tProject"|") = 0 then do
/* Project not found */
Projects = Projects||tProject"|"
nProjects = nProjects + 1
Projects.nProjects.Name = tProject
if tType = "T" then do
Projects.nProjects.count = 1
Expenses.nProjects.count = 0
end
else do
Projects.nProjects.count = 0
Expenses.nProjects.count = 1
end
cProject = nProjects; n = 1
end
else do
/* Project exists */
do lp = 1 to nProjects
if Projects.lp.Name = tProject then leave
end
cProject = lp
if tType = "T" then do
Projects.lp.count = Projects.lp.count + 1
n = Projects.lp.count
end
else do
Expenses.lp.count = Expenses.lp.count + 1
n = Expenses.lp.count
end
end
if tType = "T" then do
Projects.cProject.n.Info = tInfo
Work = 1
end
else do
Expenses.cProject.n.Info = tInfo
Expenses = 1
end
end
call close('Time')
if nProjects = 0 then do
'ShowMessage' 1 1 '"CREATE INVOICE ERROR" "NO Logged Time or Expenses" "" "OK" "" ""'
exit
end
/* Read Invoice Number */
if open('Invoice', DataPath||Client.NameCode||".invoice", 'R') then do
cInvoice = readln('Invoice')
call close('Invoice')
end
cInvoice = cInvoice + 1
Client.Invoice = right(cInvoice, 2, "0")
/* Create Invoice */
'Justify' CENTER
/* Invoice # */
'Font' "SoftSans_Bold"; 'FontSize' 24
'Type' "Invoice #"Client.NameCode''Client.Invoice
'NewParagraph'
/* Client Name */
'Font' "SoftSans_Bold"; 'FontSize' 14
'Type' Client.Name
'NewParagraph'; 'NewParagraph'
'Justify' RIGHT
/* Date */
'Font' "SoftSans_Bold"; 'FontSize' 12
'Insert' DATE
'NewParagraph'
'Justify' CENTER
'NewParagraph'
/* Work Description */
'Font' "SoftSans_Bold"; 'FontSize' 18
'Type' "Work"
'NewParagraph'
'Justify' LEFT
/* Work Description - Projects */
do lp = 1 to nProjects
if Projects.lp.Name ~= "" then do
'PasteRuler'
'Font' "SoftSans_Bold"; 'FontSize' 12
'Type' Projects.lp.Name
'NewParagraph'
'SetTab' .125 LEFT
'Font' "SoftSans"; 'FontSize' 12
'Type' tab"· "
'NewParagraph'
end
end
/* Expenses */
TotalExpenses = 0
if Expenses then do
'Justify' CENTER
'NewParagraph'
'Font' "SoftSans_Bold"; 'FontSize' 18
'Type' "Expenses"
'NewParagraph'
'Justify' LEFT
do lp = 1 to nProjects
if Expenses.lp.count = 0 then iterate
'PasteRuler'
'Font' "SoftSans_Bold"; 'FontSize' 12
'Type' Projects.lp.Name
'NewParagraph'
'Font' "SoftSans"; 'FontSize' 12
'SetTab' .125 LEFT; 'SetTab' 6.0 DECIMAL
do lp2 = 1 to Expenses.lp.count
t = Expenses.lp.lp2.Info
if index(t, '","', index(t, '","')+3) = 0 then do
parse var t '"'tInfo'","'tAmount'"'
'Type' tab''tInfo''tab''tAmount
end
else do
parse var t '"'tInfo'","'tQuantity'","'tPer'","'tAmount'"'
'Type' tab''tInfo" ("tQuantity" @ "tPer")"tab''tAmount
end
'NewParagraph'
TotalExpenses = TotalExpenses + tAmount
end
end
'PasteRuler'
'SetTab' 5.0 RIGHT; 'SetTab' 6.0 DECIMAL
'Font' "SoftSans_Bold"; 'FontSize' 14
'Type' Tab"Expenses"Tab"$"TotalExpenses
'NewParagraph'
'PasteRuler'
end
Total = 0
if Work then do
'Justify' CENTER
'NewParagraph'
/* Work Hours */
'Font' "SoftSans_Bold"; 'FontSize' 18
'Type' "Work Hours"
'NewParagraph'
'Justify' LEFT
do lp = 1 to nProjects
if Projects.lp.count = 0 then iterate
'PasteRuler'
'Font' "SoftSans_Bold"; 'FontSize' 12
'Type' Projects.lp.Name
'NewParagraph'
'SetTab' .6875 RIGHT; 'SetTab' 1.5625 RIGHT; 'SetTab' 1.625 LEFT
'SetTab' 2.4375 RIGHT; 'SetTab' 2.8125 DECIMAL
'SetTab' 4.0625 RIGHT; 'SetTab' 4.9375 RIGHT; 'SetTab' 5.0 LEFT
'SetTab' 5.8125 RIGHT; 'SetTab' 6.1875 DECIMAL
'Font' "SoftSans"; 'FontSize' 11
nLeft = trunc(Projects.lp.count / 2 + .5)
HSubTotal = 0
do lp2 = 1 to nLeft
parse var Projects.lp.lp2.Info '"'tDate'","'tT1'","'tT2'","'tH'","'tRate'"'
'Type' Tab''tDate''Tab''tT1''Tab"-"Tab''tT2''Tab''tH
'NewParagraph'
HSubTotal = HSubTotal + tH
end
if Project.lp.count ~= 1 then do
do lp2 = 1 to nLeft; 'Cursor' UP; end
'CtrlDown'; 'AltDown'; 'Cursor' RIGHT; 'AltUp'; 'CtrlUp'
do lp2 = nLeft+1 to Projects.lp.count
parse var Projects.lp.lp2.Info '"'tDate'","'tT1'","'tT2'","'tH'","'tRate'"'
'Type' Tab''tDate''Tab''tT1''Tab"-"Tab''tT2''Tab''tH
'Cursor' DOWN
HSubTotal = HSubTotal + tH
end
end
SubTotal = trunc(HSubTotal * tRate + .5e-2, 2)
'Cursor' DOWN
'PasteRuler'
'SetTab' 4.0 DECIMAL; 'SetTab' 6.0 DECIMAL
'Font' "SoftSans_Bold"; 'FontSize' 12
'Type' Tab''HSubTotal
'Font' "SoftSans"; 'FontSize' 12
'Type' " @ $"tRate" / hour"
'Font' "SoftSans_Bold"; 'FontSize' 12
'Type' Tab''SubTotal
'NewParagraph'
Total = Total + SubTotal
end
'PasteRuler'
'SetTab' 5.0 RIGHT; 'SetTab' 6.0 DECIMAL
'Font' "SoftSans_Bold"; 'FontSize' 14
'Type' Tab"Work"Tab"$"Total
end
'NewParagraph'; 'NewParagraph'
Total = Total + TotalExpenses
'PasteRuler'
'SetTab' 5.0 RIGHT; 'SetTab' 6.0 DECIMAL
'Font' "SoftSans_Bold"; 'FontSize' 18
'Type' Tab"Total"Tab"$"
'Style' UNDERLINE
'Type' Total
'Style' NORMAL
'NewParagraph'
'PasteRuler'
'NewParagraph'; 'NewParagraph'
'Type' "Payment To:"
'NewParagraph'
'Justify' CENTER
'Font' "SoftSans"; 'FontSize' 12
'Type' "scott dhomas trenn"
'NewParagraph'
'Type' "797 Mitchell Street, Fredericton, NB E3B 3S8"
'NewParagraph'
'Type' "(506) 459-7088"
/* Reposition Cursor */
'CtrlDown'; 'AltDown'; 'Cursor' UP; 'AltUp'; 'CtrlUp'
do lp = 1 to 7; 'Cursor' DOWN; end
'CtrlDown'; 'AltDown'; 'Cursor' RIGHT; 'AltUp'; 'CtrlUp'
/* Write Invoice Number */
call open('Invoice', DataPath||Client.NameCode||".invoice", 'W')
call writeln('Invoice', cInvoice)
call close('Invoice')
/* Backup .time data file */
ADDRESS COMMAND 'C:Rename' DataPath||Client.NameCode||".time" DataPath||Client.NameCode||".time."Client.Invoice
exit